﻿Imports System.Drawing

''' <summary>
''' 路径节点对象
''' </summary>
Public Class AStarNode
    Implements IAStarNode

    Sub New(ByVal loc As Point, ByVal previous As AStarNode, ByVal costG As Integer, ByVal costH As Integer)
        Me.Location = loc
        Me.PreviousNode = previous
        Me.CostG = costG
        Me.CostH = costH
    End Sub

    ''' <summary>
    ''' Location 节点所在的位置， 其X值代表ColumnIndex，Y值代表LineIndex
    ''' </summary>
    Property Location As Point Implements IAStarNode.Location

    ''' <summary>
    ''' PreviousNode 父节点，即是由哪个节点导航到当前节点的
    ''' </summary>
    Property PreviousNode As IAStarNode Implements IAStarNode.PreviousNode

    ''' <summary>
    ''' CostF 从起点导航经过本节点然后再到目的节点的估算总代价
    ''' </summary>
    ReadOnly Property CostF As Integer Implements IAStarNode.CostF
        Get
            Return CostG + CostH
        End Get
    End Property

    ''' <summary>
    ''' CostG 从起点导航到本节点的代价
    ''' </summary>
    Property CostG As Integer Implements IAStarNode.CostG

    ''' <summary>
    ''' CostH 使用启发式方法估算的从本节点到目的节点的代价
    ''' </summary>
    Property CostH As Integer Implements IAStarNode.CostH

    ''' <summary>
    ''' ResetPreviousNode 当从起点到达本节点 有更优的路径时，调用该方法采用更优的路径
    ''' </summary>
    Sub ResetPreviousNode(ByVal previous As IAStarNode, ByVal costG As Integer)
        Me.PreviousNode = previous
        Me.CostG = costG
    End Sub

End Class
